﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.Serialization;
using HighSign.Common.Applications;

namespace HighSign.Applications
{
	[DataContract]
	[KnownType(typeof(GlobalApplication))]
	public class GlobalApplication : IApplication
	{
		#region Private Instance Fields

		private List<IAction> _Actions = new List<IAction>();

		#endregion

		#region IApplication Properties

		[DataMember]
		public string Name
		{
			get { return "All Applicatons"; }
			set { /* Set only exists for deserialization purposes */ }
		}

		[DataMember]
		public MatchUsing MatchUsing
		{
			get { return MatchUsing.All; }
			set { /* Set only exists for deserialization purposes */ }
		}

		[DataMember]
		public string MatchString
		{
			get { return null; }
			set { /* Set only exists for deserialization purposes */ }
		}

		[DataMember]
		public IAction[] Actions
		{
			get { return _Actions.ToArray(); }
			set { _Actions = value.ToList(); }
		}

		#endregion

		#region IApplication Methods

		public void AddAction(IAction Action)
		{
			_Actions.Add(Action);
		}

		public void RemoveAction(IAction Action)
		{
			_Actions.Remove(Action);
		}

		public void RemoveAllActions(Predicate<IAction> Match)
		{
			_Actions.RemoveAll(Match);
		}

		#endregion
	}
}
